<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-08-14 16:07
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Transformers;


use League\Fractal\TransformerAbstract;

class getNewLikePortfolioTransformer extends TransformerAbstract
{
	private $list;
	public function __construct($list)
	{
		$this->list = $list;
	}

	public function transform(){
		$result = [];
		foreach ($this->list as $v){
			empty($v->portfolio) ? : empty($v->portfolio->user) ? : empty($v->portfolio->user->picture) ? : $result['user_portrait'][$v->user_id.'-'.$v->store_id] = $v->portfolio->user->picture->image;
			empty($v->portfolio) ? : empty($v->portfolio->resource) ? : empty($v->portfolio->resource->video) ? :$result['video_thumb'][$v->user_id.'-'.$v->store_id] = $v->portfolio->resource->video->thumb;
		}
		if(!empty($result)){
			$result['user_portrait'] = array_values($result['user_portrait']);
			$result['video_thumb'] = array_values($result['video_thumb']);
		};
		return $result;
	}

}